package leetcodecompetition.S101;

import java.util.HashSet;
import java.util.Set;

public class T6327 {
    public int minNumber(int[] nums1, int[] nums2) {
        int a = nums1[0];
        int b = nums2[0];
        int c=11;
        Set<Integer> set=new HashSet<>();
        set.add(nums1[0]);
        for (int i = 1; i < nums1.length; i++) {
            a = Math.min(a, nums1[i]);
            set.add(nums1[i]);
        }
        if (set.contains(nums2[0])){
            c=nums2[0];
        }
        for (int i = 1; i < nums2.length; i++) {
            b = Math.min(b, nums2[i]);
            if (set.contains(nums2[i])){
                c=Math.min(nums2[i],c);
            }
        }
        if (c!=11)return c;
        if(a>b)return a+b*10;
        return a*10+b;
    }
}
